#include "RandomNumber.h"
#include <ctime>

RandomNumber::RandomNumber(unsigned long seed)
{
	if (seed == 0)
		randomSeed = time(NULL);
	else
		randomSeed = seed;
}

void RandomNumber::setRandomSeed(unsigned long seed)
{
	if (seed == 0)
		randomSeed = time(NULL);
	else
		randomSeed = seed;
}

unsigned short RandomNumber::nextInt(unsigned long max)
{
	randomSeed = multiplier*randomSeed + adder;
	return(unsigned short)((randomSeed >> 16) % max);
}

double RandomNumber::nextDouble()
{
	return nextInt() / double(maxshort);
}